% MANDELBROT_00 Not optimised Mandelbrot function.
%
% NOTE: On purpose, this code contains a bug and some superfluous code.
%
% HISTORY
%
%   20090701 KP - Initial version
%   20100506 KP - Allowing a center different from the origin
%
% AUTHOR
%
%   Koen Poppe, Department of Computer Science,
%   Katholieke Universiteit Leuven, Celestijnenlaan 200A,
%   B-3001 Heverlee, Belgium
%   Email:  Koen.Poppe@cs.kuleuven.be
%
function R_tilde=mandelbrot_10(center,radius,steps,maxiter)
C=zeros(steps,steps);
for m=1:steps
    for n=1:steps
        C(m,n) = real(center)-radius+2*(n-1)*radius/(steps-1) ...
            + 1i*(imag(center)-radius+2*(m-1)*radius/(steps-1));
    end
end
Z=C;
R_tilde=ones(steps,steps)*maxiter;
mr = 1:steps*steps;
for r=1:maxiter
    mr = mr(R_tilde(mr)==maxiter);
    Z(mr) = Z(mr).^2 + C(mr);
    R_tilde(mr(abs(Z(mr))>2)) = r;
end